package com.tgu.home_action.service.impl;

import com.tgu.home_action.pojo.state.RabbitMq;
import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

@Component
public class ApplicationRunnerImpl implements ApplicationRunner {
    @Autowired
    private AmqpAdmin amqpAdmin;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        //创建控制志愿者位置的交换机
//        amqpAdmin.declareExchange(new FanoutExchange(RabbitMq.VOLUNTEER_PLACE_EXCHANGE.getValue()));
//        //创建储存志愿者位置的队列和Binding
//        amqpAdmin.declareQueue(new Queue(RabbitMq.VOLUNTEER_PLACE_SAVE.getValue()));
//        amqpAdmin.declareBinding(new Binding(RabbitMq.VOLUNTEER_PLACE_SAVE.getValue(), Binding.DestinationType.QUEUE,
//                RabbitMq.VOLUNTEER_PLACE_EXCHANGE.getValue(),RabbitMq.VOLUNTEER_PLACE_SAVE.getValue(),null));
//        //创建发送志愿者位置的队列和Binding
//        amqpAdmin.declareQueue(new Queue(RabbitMq.VOLUNTEER_PLACE_SEND.getValue()));
//        amqpAdmin.declareBinding(new Binding(RabbitMq.VOLUNTEER_PLACE_SEND.getValue(), Binding.DestinationType.QUEUE,
//                RabbitMq.VOLUNTEER_PLACE_EXCHANGE.getValue(),RabbitMq.VOLUNTEER_PLACE_SEND.getValue(),null));
//
//        //创建控制案件的交换机
//        amqpAdmin.declareExchange(new DirectExchange(RabbitMq.CASE_EXCHANGE.getValue()));
//        //创建发送短信的队列和Binding
//        amqpAdmin.declareQueue(new Queue(RabbitMq.CASE_SEND.getValue()));
//        amqpAdmin.declareBinding(new Binding(RabbitMq.CASE_SEND.getValue(), Binding.DestinationType.QUEUE,
//                RabbitMq.CASE_EXCHANGE.getValue(),RabbitMq.CASE_SEND .getValue(),null));
//        //创建案件信息变更的队列和Binding
//        amqpAdmin.declareQueue(new Queue(RabbitMq.CASE_INFORMATION_UPDATE.getValue()));
//        amqpAdmin.declareBinding(new Binding(RabbitMq.CASE_INFORMATION_UPDATE.getValue(), Binding.DestinationType.QUEUE,
//                RabbitMq.CASE_EXCHANGE.getValue(),RabbitMq.CASE_INFORMATION_UPDATE.getValue(),null));

//        amqpAdmin.declareQueue(new Queue("case.finish"));
//        amqpAdmin.declareBinding(new Binding("case.finish", Binding.DestinationType.QUEUE,
//                RabbitMq.CASE_EXCHANGE.getValue(),"case.finish",null));
//        amqpAdmin.declareQueue(new Queue(RabbitMq.CASE_END.getValue()));
//        amqpAdmin.declareBinding(new Binding(RabbitMq.CASE_END.getValue(), Binding.DestinationType.QUEUE,
//                RabbitMq.CASE_EXCHANGE.getValue(),RabbitMq.CASE_END.getValue(),null));
    }
}
